<?php
include_once 'config.php';

if (!mysql_connect($host, $user, $password)) {
    echo "Sorry unable to connect database" . mysql_error();
}

if (!mysql_select_db($dbname)) {
    die("Cannot connect to the Database" . mysql_error($link));
}
function auth($username, $password,$user) {

    $result = mysql_query("SELECT * FROM user WHERE username='$username' AND password='$password' AND Usertype='$user'");
    if (!$result) {
        die('Invalid query: ' . mysql_error());
    }
    if (mysql_num_rows($result) == 1) {
        mysql_free_result($result);
		
        return true;
    } else {
        mysql_free_result($result);
        return false;
    }
}
function user_loggedin() {
    if (isset($_SESSION['username']) && isset($_SESSION['password'])) {
	
	
	
        if (!auth($_SESSION['username'], $_SESSION['password'],$result['Usertype'])) {
           
		   return true;
			
        }
		/*else if(!auth($_SESSION['username'], $_SESSION['password'],$result['Usertype']))
		{
		echo "DSD";
		//return true;
		}*/

		else {
            return false;
        }
    }
	}





?>